home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / pmode / pmode386 / example1.asm < prev    next >
Encoding:
Assembly Source File  |  1993-05-29  |  2.9 KB  |  92 lines

  1. ; Example program #1
  2. ; This one demonstrates possible IRQ screwups under VCPI and DPMI.
  3. ; When it starts, there should be 2 boxes flashing on and off in the upper
  4. ; right of the screen. Then when you press a key, nothing should change. But
  5. ; unfortunately, under VCPI, one of the boxes will stop blinking. This is when
  6. ; control passes to the real mode BIOS key routine. As it waits in real mode,
  7. ; protected control is in the hands of the VCPI server. And this program will
  8. ; not regain control for its IRQ handlers. Under DPMI both boxes should
  9. ; continue to blink just like in raw mode. But sometimes they may not. This
  10. ; is when the DPMI host is not reflecting the IRQs correctly.
  11.  
  12.         .386p
  13.         jumps
  14.  
  15. code16  segment para public use16
  16.         assume cs:code16, ds:code16
  17.  
  18. ;─────────────────────────────────────────────────────────────────────────────
  19. nrirq0:
  20.         push ax ds
  21.         mov ax,0b800h
  22.         mov ds,ax
  23.         xor byte ptr ds:[156],91h
  24.         pop ds
  25.         mov al,20h
  26.         out 20h,al
  27.         sti
  28.         pop ax
  29.         iret
  30.  
  31. code16  ends
  32.  
  33. code32  segment para public use32
  34.         assume cs:code32, ds:code32
  35.  
  36. include pmode.inc
  37.  
  38. public  _main
  39.  
  40. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  41. ; DATA
  42. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  43. oirq0           dd      ?
  44. orirq0          dd      ?
  45.  
  46. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  47. ; CODE
  48. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  49.  
  50. ;─────────────────────────────────────────────────────────────────────────────
  51. nirq0:
  52.         push ds
  53.         mov ds,cs:_selzero
  54.         xor byte ptr ds:[0b8000h+158],0fbh
  55.         pop ds
  56.         jmp cs:oirq0                    ; chain to old IRQ0 redirector
  57. ;═════════════════════════════════════════════════════════════════════════════
  58. _main:
  59.         mov dword ptr gs:[0b8000h+156],0f200f20h        ; clear upper right
  60.  
  61.         xor bl,bl                       ; hook into pmode IRQ0 redirector
  62.         call _getirqvect
  63.         mov oirq0,edx
  64.         mov edx,offset nirq0
  65.         call _setirqvect
  66.  
  67.         mov eax,gs:[20h]                ; replace real mode IRQ0 handler
  68.         mov orirq0,eax
  69.         mov word ptr gs:[20h],offset nrirq0
  70.         mov word ptr gs:[22h],code16
  71.         sti
  72.  
  73. mainl0:                                 ; wait in pmode for key
  74.         mov ax,gs:[41ah]
  75.         cmp ax,gs:[41ch]
  76.         je mainl0
  77.         mov al,16h                      ; get key to clear buffer
  78.         mov v86r_ah,0
  79.         int 33h
  80.  
  81.         mov al,16h                      ; wait for key in real mode
  82.         mov v86r_ah,0
  83.         int 33h
  84.  
  85.         mov eax,orirq0                  ; must replace real mode int vect
  86.         mov gs:[20h],eax
  87.         jmp _exit
  88.  
  89. code32  ends
  90.         end
  91.  
  92.